package com.carp.springframework.beans;

import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * @author lile
 * @date 2023/2/9
 */
@Getter
public class PropertyValues {

    private final List<PropertyValue> propertyValueList = new ArrayList<>();

    public void addPropertyValue(String name, Object value) {
        PropertyValue pv = new PropertyValue(name, value);
        for (int i = 0; i < propertyValueList.size(); i++) {
            PropertyValue currentPv = propertyValueList.get(i);
            if (currentPv.getName().equals(name)) {
                propertyValueList.set(i, pv);
                return;
            }
        }
        propertyValueList.add(pv);
    }

}
